package cn.stylefeng.guns.modular.gridsystem.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.factory.PageResultFactory;
import cn.stylefeng.guns.core.pojo.base.param.BaseParam;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.gridsystem.model.param.SoundCardParam;
import cn.stylefeng.guns.modular.gridsystem.service.SoundCardService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 声卡 控制器
 *
 * @author: zxw
 * @date: 2022/10/31 14:34
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/soundCard")
public class SoundCardController {

    private final SoundCardService service;

    /**
     * 分页查询声卡
     *
     * @author zxw
     * @date 2022/10/31 14:34
     */
    @GetMapping("/page")
    @BusinessLog(title = "声卡_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(SoundCardParam param) {
        return new SuccessResponseData(PageResultFactory.createPageResult(service.page(param)));
    }

    /**
     * 获取全部声卡
     *
     * @author zxw
     * @date 2022/10/31 14:34
     */
    @GetMapping("/list")
    @BusinessLog(title = "声卡_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(SoundCardParam param) {
        return new SuccessResponseData(service.list(param));
    }

    /**
     * 添加声卡
     *
     * @author zxw
     * @date 2022/10/31 14:34
     */
    @PostMapping("/add")
    @BusinessLog(title = "声卡_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(BaseParam.add.class) SoundCardParam param) {
        service.add(param);
        return new SuccessResponseData();
    }

    /**
     * 删除声卡
     *
     * @author zxw
     * @date 2022/10/31 14:34
     */
    @PostMapping("/delete")
    @BusinessLog(title = "声卡_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(BaseParam.delete.class) SoundCardParam param) {
        service.delete(param);
        return new SuccessResponseData();
    }

    /**
     * 编辑声卡
     *
     * @author zxw
     * @date 2022/10/31 14:34
     */
    @PostMapping("/edit")
    @BusinessLog(title = "声卡_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(BaseParam.edit.class) SoundCardParam param) {
        service.edit(param);
        return new SuccessResponseData();
    }

}
